package com.example.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.BusSystemReceivemsgMapper;
import com.example.service.BusSystemReceivemsgService;
import com.example.system.domain.BusSystemReceivemsg;
import com.example.util.sql.DBSql;
import com.example.util.sql.SqlGenerator;
import com.example.util.sql.SqlResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.sql.DataSource;
import java.util.Collections;
import java.util.List;

/**
* @author CETC
* @description 针对表【bus_system_receivemsg_1】的数据库操作Service实现
* @createDate 2025-10-25 13:52:39
*/
@Service
public class BusSystemReceivemsgServiceImpl extends ServiceImpl<BusSystemReceivemsgMapper, BusSystemReceivemsg>
    implements BusSystemReceivemsgService {

    @Autowired
    private DataSource dataSource;

    @Override
    public BusSystemReceivemsg saveBusSystemReceivemsg(String tableName,BusSystemReceivemsg receivemsg) {
        DBSql dbSql=new DBSql(dataSource);
        SqlResult sqlResult=SqlGenerator.generateInsert(tableName,receivemsg);
        System.out.println("sql:"+sqlResult.getSql()+" params "+ JSONObject.toJSONString(sqlResult.getParams()));
        dbSql.executeInsert(sqlResult.getSql(),sqlResult.getParams().toArray());
        return receivemsg;
    }

    @Override
    public List<BusSystemReceivemsg> getList(String tableName,String uid) {
        return this.baseMapper.selectByBusTableNameAll(tableName,uid);
    }

    @Override
    public List<BusSystemReceivemsg> getList(String tableName, String uid, String formUid) {
        return this.baseMapper.selectByBusTableName(tableName,uid,formUid);
    }

    @Override
    public IPage<BusSystemReceivemsg> getPage(Page<BusSystemReceivemsg> page, String tableName, String uid) {
        return this.baseMapper.selectPageAll(tableName,uid,page);
    }

    @Override
    public IPage<BusSystemReceivemsg> getPage(Page<BusSystemReceivemsg> page, String tableName, String uid, String formUid) {
        return this.baseMapper.selectPage(tableName,uid,formUid,page);
    }
}




